package com.qfedu.zf.my.controller;

import com.qfedu.lc.common.entity.UserMes;
import com.qfedu.zf.common.utils.JwtUtil;
import com.qfedu.zf.common.vo.R;
import com.qfedu.zf.my.service.UserMesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("my")
@CrossOrigin
public class UserMesController {
    @Autowired
    private UserMesService userMesService;

    @PostMapping("/authentication")
    public R authentication(@RequestBody UserMes userMes, HttpServletRequest request){
        String lctoken = request.getHeader("Lctoken");
        Object id = JwtUtil.parseToken(lctoken, "id");
        String s = id.toString();
        int i = Integer.parseInt(s);
        userMes.setUserId(i);
        return userMesService.authentication(userMes);
    }
}
